<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>drilldownrow.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_ui_drilldownrow.js.html">drilldownrow.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line2"></a>// you may not use this file except in compliance with the License.
<a name="line3"></a>// You may obtain a copy of the License at
<a name="line4"></a>//
<a name="line5"></a>//     http://www.apache.org/licenses/LICENSE-2.0
<a name="line6"></a>//
<a name="line7"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line8"></a>// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<a name="line9"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line10"></a>// See the License for the specific language governing permissions and
<a name="line11"></a>// limitations under the License.
<a name="line12"></a>
<a name="line13"></a>// Copyright 2007 Google Inc. All Rights Reserved.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Tree-like drilldown components for HTML tables.
<a name="line17"></a> *
<a name="line18"></a> * This component supports expanding and collapsing groups of rows in
<a name="line19"></a> * HTML tables.  The behavior is like typical Tree widgets, but tables
<a name="line20"></a> * need special support to enable the tree behaviors.
<a name="line21"></a> *
<a name="line22"></a> * Any row or rows in an HTML table can be DrilldownRows.  The root
<a name="line23"></a> * DrilldownRow nodes are always visible in the table, but the rest show
<a name="line24"></a> * or hide as input events expand and collapse their ancestors.
<a name="line25"></a> *
<a name="line26"></a> * Programming them:  Top-level DrilldownRows are made by decorating
<a name="line27"></a> * a TR element.  Children are made with addChild or addChildAt, and
<a name="line28"></a> * are entered into the document by the render() method.
<a name="line29"></a> *
<a name="line30"></a> * A DrilldownRow can have any number of children.  If it has no children
<a name="line31"></a> * it can be loaded, not loaded, or with a load in progress.
<a name="line32"></a> * Top-level DrilldownRows are always displayed (though setting
<a name="line33"></a> * style.display on a containing DOM node could make one be not
<a name="line34"></a> * visible to the user).  A DrilldownRow can be expanded, or not.  A
<a name="line35"></a> * DrilldownRow displays if all of its ancestors are expanded.
<a name="line36"></a> *
<a name="line37"></a> * Set up event handlers and style each row for the application in an
<a name="line38"></a> * enterDocument method.
<a name="line39"></a> *
<a name="line40"></a> * Children normally render into the document lazily, at the first
<a name="line41"></a> * moment when all ancestors are expanded.
<a name="line42"></a> *
<a name="line43"></a> */
<a name="line44"></a>
<a name="line45"></a>// TODO: Build support for dynamically loading DrilldownRows,
<a name="line46"></a>// probably using automplete as an example to follow.
<a name="line47"></a>
<a name="line48"></a>// TODO: Make DrilldownRows accessible through the keyboard.
<a name="line49"></a>
<a name="line50"></a>// The render method is redefined in this class because when addChildAt renders
<a name="line51"></a>// the new child it assumes that the child&#39;s DOM node will be a child
<a name="line52"></a>// of the parent component&#39;s DOM node, but all DOM nodes of DrilldownRows
<a name="line53"></a>// in the same tree of DrilldownRows are siblings to each other.
<a name="line54"></a>//
<a name="line55"></a>// Arguments (or lack of arguments) to the render methods in Component
<a name="line56"></a>// all determine the place of the new DOM node in the DOM tree, but
<a name="line57"></a>// the place of a new DrilldownRow in the DOM needs to be determined by
<a name="line58"></a>// its position in the tree of DrilldownRows.
<a name="line59"></a>
<a name="line60"></a>goog.provide(&#39;goog.ui.DrilldownRow&#39;);
<a name="line61"></a>
<a name="line62"></a>goog.require(&#39;goog.dom&#39;);
<a name="line63"></a>goog.require(&#39;goog.dom.classes&#39;);
<a name="line64"></a>goog.require(&#39;goog.events&#39;);
<a name="line65"></a>goog.require(&#39;goog.ui.Component&#39;);
<a name="line66"></a>
<a name="line67"></a>
<a name="line68"></a>/**
<a name="line69"></a> * Builds a DrilldownRow component, which can overlay a tree
<a name="line70"></a> * structure onto sections of an HTML table.
<a name="line71"></a> *
<a name="line72"></a> * @param {Object} opt_properties This parameter can contain:
<a name="line73"></a> *   contents:  if present, user data identifying
<a name="line74"></a> *     the information loaded into the row and its children.
<a name="line75"></a> *   loaded: initializes the isLoaded property, defaults to true.
<a name="line76"></a> *   expanded: DrilldownRow expanded or not, default is true.
<a name="line77"></a> *   html: String of HTML, relevant and required for DrilldownRows to be
<a name="line78"></a> *     added as children.  Ignored when decorating an existing table row.
<a name="line79"></a> *   decorator: Function that accepts one DrilldownRow argument, and
<a name="line80"></a> *     should customize and style the row.  The default is to call
<a name="line81"></a> *     goog.ui.DrilldownRow.decorator.
<a name="line82"></a> * @constructor
<a name="line83"></a> * @extends {goog.ui.Component}
<a name="line84"></a> */
<a name="line85"></a>goog.ui.DrilldownRow = function(opt_properties) {
<a name="line86"></a>  goog.ui.Component.call(this);
<a name="line87"></a>  var properties = opt_properties || {};
<a name="line88"></a>
<a name="line89"></a>  // Initialize instance variables.
<a name="line90"></a>
<a name="line91"></a>  /**
<a name="line92"></a>   * String of HTML to initialize the DOM structure for the table row.
<a name="line93"></a>   * Should have the form &#39;&lt;tr attr=&quot;etc&quot;&gt;Row contents here&lt;/tr&gt;&#39;.
<a name="line94"></a>   * @type {string}
<a name="line95"></a>   * @private
<a name="line96"></a>   */
<a name="line97"></a>  this.html_ = properties.html;
<a name="line98"></a>
<a name="line99"></a>  /**
<a name="line100"></a>   * Controls whether this component&#39;s children will show when it shows.
<a name="line101"></a>   * @type {boolean}
<a name="line102"></a>   * @private
<a name="line103"></a>   */
<a name="line104"></a>  this.expanded_ = typeof properties.expanded != &#39;undefined&#39; ?
<a name="line105"></a>      properties.expanded : true;
<a name="line106"></a>
<a name="line107"></a>  /**
<a name="line108"></a>   * Is this component loaded? States are true, false, and null for
<a name="line109"></a>   * &#39;loading in progress&#39;.  For in-memory
<a name="line110"></a>   * trees of components, this is always true.
<a name="line111"></a>   * @type {boolean}
<a name="line112"></a>   * @private
<a name="line113"></a>   */
<a name="line114"></a>  this.loaded_ = typeof properties.loaded != &#39;undefined&#39; ?
<a name="line115"></a>      properties.loaded : true;
<a name="line116"></a>
<a name="line117"></a>  /**
<a name="line118"></a>   * If this component&#39;s DOM element is created from a string of
<a name="line119"></a>   * HTML, this is the function to call when it is entered into the DOM tree.
<a name="line120"></a>   * @type {Function} args are DrilldownRow and goog.events.EventHandler
<a name="line121"></a>   *   of the DrilldownRow.
<a name="line122"></a>   * @private
<a name="line123"></a>   */
<a name="line124"></a>  this.decoratorFn_ = properties.decorator || goog.ui.DrilldownRow.decorate;
<a name="line125"></a>
<a name="line126"></a>  /**
<a name="line127"></a>   * Is the DrilldownRow to be displayed?  If it is rendered, this mirrors
<a name="line128"></a>   * the style.display of the DrilldownRow&#39;s row.
<a name="line129"></a>   * @type {boolean}
<a name="line130"></a>   * @private
<a name="line131"></a>   */
<a name="line132"></a>  this.displayed_ = true;
<a name="line133"></a>};
<a name="line134"></a>goog.inherits(goog.ui.DrilldownRow, goog.ui.Component);
<a name="line135"></a>
<a name="line136"></a>
<a name="line137"></a>/**
<a name="line138"></a> * Example object with properties of the form accepted by the class
<a name="line139"></a> * constructor.  These are educational and show the compiler that
<a name="line140"></a> * these properties can be set so it doesn&#39;t emit warnings.
<a name="line141"></a> */
<a name="line142"></a>goog.ui.DrilldownRow.sampleProperties = {
<a name="line143"></a>  &#39;html&#39;: &#39;&lt;tr&gt;&lt;td&gt;Sample&lt;/td&gt;&lt;td&gt;Sample&lt;/tr&gt;&#39;,
<a name="line144"></a>  &#39;loaded&#39;: true,
<a name="line145"></a>  &#39;decorator&#39;: function(selfObj, handler) {
<a name="line146"></a>    // When the mouse is hovering, add CSS class goog-drilldown-hover.
<a name="line147"></a>    goog.ui.DrilldownRow.decorate(selfObj);
<a name="line148"></a>    var row = selfObj.getElement();
<a name="line149"></a>    handler.listen(row, &#39;mouseover&#39;, function() {
<a name="line150"></a>      goog.dom.classes.add(row, &#39;goog-drilldown-hover&#39;);
<a name="line151"></a>    });
<a name="line152"></a>    handler.listen(row, &#39;mouseout&#39;, function() {
<a name="line153"></a>      goog.dom.classes.remove(row, &#39;goog-drilldown-hover&#39;);
<a name="line154"></a>    })
<a name="line155"></a>  }
<a name="line156"></a>};
<a name="line157"></a>
<a name="line158"></a>
<a name="line159"></a>//
<a name="line160"></a>// Implementations of Component methods.
<a name="line161"></a>//
<a name="line162"></a>
<a name="line163"></a>/**
<a name="line164"></a> * The base class method calls its superclass method and this
<a name="line165"></a> * drilldown&#39;s &#39;decorator&#39; method as defined in the constructor.
<a name="line166"></a> */
<a name="line167"></a>goog.ui.DrilldownRow.prototype.enterDocument = function() {
<a name="line168"></a>  goog.ui.DrilldownRow.superClass_.enterDocument.call(this);
<a name="line169"></a>  this.decoratorFn_(this, this.getHandler());
<a name="line170"></a>};
<a name="line171"></a>
<a name="line172"></a>
<a name="line173"></a>/** @inheritDoc */
<a name="line174"></a>goog.ui.DrilldownRow.prototype.createDom = function() {
<a name="line175"></a>  this.setElementInternal(goog.ui.DrilldownRow.createRowNode_(
<a name="line176"></a>      this.html_, this.getDomHelper().getDocument()));
<a name="line177"></a>};
<a name="line178"></a>
<a name="line179"></a>
<a name="line180"></a>/**
<a name="line181"></a> * A top-level DrilldownRow decorates a TR element.
<a name="line182"></a> *
<a name="line183"></a> * @param {Element} node The element to test for decorability.
<a name="line184"></a> * @return {boolean} true iff the node is a TR.
<a name="line185"></a> */
<a name="line186"></a>goog.ui.DrilldownRow.prototype.canDecorate = function(node) {
<a name="line187"></a>  return node.tagName == &#39;TR&#39;;
<a name="line188"></a>};
<a name="line189"></a>
<a name="line190"></a>
<a name="line191"></a>/**
<a name="line192"></a> * Child drilldowns are rendered when needed.
<a name="line193"></a> *
<a name="line194"></a> * @param {goog.ui.DrilldownRow} child New child to be added.
<a name="line195"></a> * @param {number} index position to be occupied by the child.
<a name="line196"></a> * @param {boolean} opt_render true to force immediate rendering.
<a name="line197"></a> */
<a name="line198"></a>goog.ui.DrilldownRow.prototype.addChildAt = function(child, index, opt_render) {
<a name="line199"></a>  goog.ui.DrilldownRow.superClass_.addChildAt.call(this, child, index, false);
<a name="line200"></a>  child.setDisplayable_(this.isVisible_() &amp;&amp; this.isExpanded());
<a name="line201"></a>  if (opt_render &amp;&amp; !child.isInDocument()) {
<a name="line202"></a>    child.render();
<a name="line203"></a>  }
<a name="line204"></a>};
<a name="line205"></a>
<a name="line206"></a>
<a name="line207"></a>/** @inheritDoc */
<a name="line208"></a>goog.ui.DrilldownRow.prototype.removeChild = function(child) {
<a name="line209"></a>  goog.dom.removeNode(child.getElement());
<a name="line210"></a>  goog.ui.DrilldownRow.superClass_.removeChild.call(this, child);
<a name="line211"></a>};
<a name="line212"></a>
<a name="line213"></a>
<a name="line214"></a>/** @inheritDoc */
<a name="line215"></a>goog.ui.DrilldownRow.prototype.disposeInternal = function() {
<a name="line216"></a>  delete this.html_;
<a name="line217"></a>  this.children_ = null;
<a name="line218"></a>  goog.ui.DrilldownRow.superClass_.disposeInternal.call(this);
<a name="line219"></a>};
<a name="line220"></a>
<a name="line221"></a>
<a name="line222"></a>/**
<a name="line223"></a> * Rendering of DrilldownRow&#39;s is on need, do not call this directly
<a name="line224"></a> * from application code.
<a name="line225"></a> *
<a name="line226"></a> * Rendering a DrilldownRow places it according to its position in its
<a name="line227"></a> * tree of DrilldownRows.  DrilldownRows cannot be placed any other
<a name="line228"></a> * way so this method does not use any arguments.  This does not call
<a name="line229"></a> * the base class method and does not modify any of this
<a name="line230"></a> * DrilldownRow&#39;s children.
<a name="line231"></a> */
<a name="line232"></a>goog.ui.DrilldownRow.prototype.render = function() {
<a name="line233"></a>  if (arguments.length) {
<a name="line234"></a>    throw Error(&#39;A DrilldownRow cannot be placed under a specific parent.&#39;);
<a name="line235"></a>  } else {
<a name="line236"></a>    var parent = this.getParent();
<a name="line237"></a>    if (!parent.isInDocument()) {
<a name="line238"></a>      throw Error(&#39;Cannot render child of un-rendered parent&#39;);
<a name="line239"></a>    }
<a name="line240"></a>    // The new child&#39;s TR node needs to go just after the last TR
<a name="line241"></a>    // of the part of the parent&#39;s subtree that is to the left
<a name="line242"></a>    // of this.  The subtree includes the parent.
<a name="line243"></a>    var previous = parent.previousRenderedChild_(this);
<a name="line244"></a>    var row;
<a name="line245"></a>    if (previous) {
<a name="line246"></a>      row = previous.lastRenderedLeaf_().getElement();
<a name="line247"></a>    } else {
<a name="line248"></a>      row = parent.getElement();
<a name="line249"></a>    }
<a name="line250"></a>    row = /** @type {Element} */ (row.nextSibling);
<a name="line251"></a>    // Render the child row component into the document.
<a name="line252"></a>    if (row) {
<a name="line253"></a>      this.renderBefore(row);
<a name="line254"></a>    } else {
<a name="line255"></a>      // Render at the end of the parent of this DrilldownRow&#39;s
<a name="line256"></a>      // DOM element.
<a name="line257"></a>      var tbody = /** @type {Element} */ (parent.getElement().parentNode);
<a name="line258"></a>      goog.ui.DrilldownRow.superClass_.render.call(this, tbody);
<a name="line259"></a>    }
<a name="line260"></a>  }
<a name="line261"></a>};
<a name="line262"></a>
<a name="line263"></a>
<a name="line264"></a>/**
<a name="line265"></a> * Finds the numeric index of this child within its parent Component.
<a name="line266"></a> * Throws an exception if it has no parent.
<a name="line267"></a> *
<a name="line268"></a> * @return {number} index of this within the children of the parent Component.
<a name="line269"></a> */
<a name="line270"></a>goog.ui.DrilldownRow.prototype.findIndex = function() {
<a name="line271"></a>  var parent = this.getParent();
<a name="line272"></a>  if (!parent) {
<a name="line273"></a>    throw Error(&#39;Component has no parent&#39;);
<a name="line274"></a>  }
<a name="line275"></a>  for (var i = 0; i &lt; parent.getChildCount(); i++) {
<a name="line276"></a>    if (parent.getChildAt(i) == this) {
<a name="line277"></a>      return i;
<a name="line278"></a>    }
<a name="line279"></a>  }
<a name="line280"></a>};
<a name="line281"></a>
<a name="line282"></a>
<a name="line283"></a>//
<a name="line284"></a>// Type-specific operations
<a name="line285"></a>//
<a name="line286"></a>
<a name="line287"></a>
<a name="line288"></a>/**
<a name="line289"></a> * Returns the expanded state of the DrilldownRow.
<a name="line290"></a> *
<a name="line291"></a> * @return {boolean} true iff this is expanded.
<a name="line292"></a> */
<a name="line293"></a>goog.ui.DrilldownRow.prototype.isExpanded = function() {
<a name="line294"></a>  return this.expanded_;
<a name="line295"></a>};
<a name="line296"></a>
<a name="line297"></a>
<a name="line298"></a>/**
<a name="line299"></a> * Sets the expanded state of this DrilldownRow: makes all children
<a name="line300"></a> * displayable or not displayable corresponding to the expanded state.
<a name="line301"></a> *
<a name="line302"></a> * @param {boolean} expanded whether this should be expanded or not.
<a name="line303"></a> */
<a name="line304"></a>goog.ui.DrilldownRow.prototype.setExpanded = function(expanded) {
<a name="line305"></a>  if (expanded != this.expanded_) {
<a name="line306"></a>    this.expanded_ = expanded;
<a name="line307"></a>    goog.dom.classes.toggle(this.getElement(), &#39;goog-drilldown-expanded&#39;);
<a name="line308"></a>    goog.dom.classes.toggle(this.getElement(), &#39;goog-drilldown-collapsed&#39;);
<a name="line309"></a>    if (this.isVisible_()) {
<a name="line310"></a>      this.forEachChild(function(child) {
<a name="line311"></a>        child.setDisplayable_(expanded);
<a name="line312"></a>      });
<a name="line313"></a>    }
<a name="line314"></a>  }
<a name="line315"></a>};
<a name="line316"></a>
<a name="line317"></a>
<a name="line318"></a>/**
<a name="line319"></a> * Returns this DrilldownRow&#39;s level in the tree.  Top level is 1.
<a name="line320"></a> *
<a name="line321"></a> * @return {number} depth of this DrilldownRow in its tree of drilldowns.
<a name="line322"></a> */
<a name="line323"></a>goog.ui.DrilldownRow.prototype.getDepth = function() {
<a name="line324"></a>  for (var component = this, depth = 0;
<a name="line325"></a>       component instanceof goog.ui.DrilldownRow;
<a name="line326"></a>       component = component.getParent(), depth++) {}
<a name="line327"></a>  return depth;
<a name="line328"></a>};
<a name="line329"></a>
<a name="line330"></a>
<a name="line331"></a>/**
<a name="line332"></a> * This static function is a default decorator that adds HTML at the
<a name="line333"></a> * beginning of the first cell to display indentation and an expander
<a name="line334"></a> * image; sets up a click handler on the toggler; initializes a class
<a name="line335"></a> * for the row: either goog-drilldown-expanded or
<a name="line336"></a> * goog-drilldown-collapsed, depending on the initial state of the
<a name="line337"></a> * DrilldownRow; and sets up a click event handler on the toggler
<a name="line338"></a> * element.
<a name="line339"></a> *
<a name="line340"></a> * This creates a DIV with class=toggle.  Your application can set up
<a name="line341"></a> * CSS style rules something like this:
<a name="line342"></a> *
<a name="line343"></a> * tr.goog-drilldown-expanded .toggle {
<a name="line344"></a> *   background-image: url(&#39;minus.png&#39;);
<a name="line345"></a> * }
<a name="line346"></a> *
<a name="line347"></a> * tr.goog-drilldown-collapsed .toggle {
<a name="line348"></a> *   background-image: url(&#39;plus.png&#39;);
<a name="line349"></a> * }
<a name="line350"></a> *
<a name="line351"></a> * These background images show whether the DrilldownRow is expanded.
<a name="line352"></a> *
<a name="line353"></a> * @param {goog.ui.DrilldownRow} selfObj DrilldownRow to be decorated.
<a name="line354"></a> */
<a name="line355"></a>goog.ui.DrilldownRow.decorate = function(selfObj) {
<a name="line356"></a>  var depth = selfObj.getDepth();
<a name="line357"></a>  var row = selfObj.getElement();
<a name="line358"></a>  if (!row.cells) {
<a name="line359"></a>    throw Error(&#39;No cells&#39;);
<a name="line360"></a>  }
<a name="line361"></a>  var cell = row.cells[0];
<a name="line362"></a>  var html = &#39;&lt;div style=&quot;float: left; width: &#39; + depth +
<a name="line363"></a>      &#39;em;&quot;&gt;&lt;div class=toggle style=&quot;width: 1em; float: right;&quot;&gt;&#39; +
<a name="line364"></a>      &#39;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&#39;;
<a name="line365"></a>  var fragment = selfObj.getDomHelper().htmlToDocumentFragment(html);
<a name="line366"></a>  cell.insertBefore(fragment, cell.firstChild);
<a name="line367"></a>  goog.dom.classes.add(row,
<a name="line368"></a>                       selfObj.isExpanded() ?
<a name="line369"></a>                       &#39;goog-drilldown-expanded&#39; :
<a name="line370"></a>                       &#39;goog-drilldown-collapsed&#39;);
<a name="line371"></a>  // Default mouse event handling:
<a name="line372"></a>  var toggler = fragment.getElementsByTagName(&#39;div&#39;)[0];
<a name="line373"></a>  var key = selfObj.getHandler().listen(toggler, &#39;click&#39;, function(event) {
<a name="line374"></a>    selfObj.setExpanded(!selfObj.isExpanded());
<a name="line375"></a>  });
<a name="line376"></a>};
<a name="line377"></a>
<a name="line378"></a>
<a name="line379"></a>//
<a name="line380"></a>// Private methods
<a name="line381"></a>//
<a name="line382"></a>
<a name="line383"></a>/**
<a name="line384"></a> * Turn display of a DrilldownRow on or off.  If the DrilldownRow has not
<a name="line385"></a> * yet been rendered, this renders it.  This propagates the effect
<a name="line386"></a> * of the change recursively as needed -- children displaying iff the
<a name="line387"></a> * parent is displayed and expanded.
<a name="line388"></a> *
<a name="line389"></a> * @param {boolean} display state, true iff display is desired.
<a name="line390"></a> * @private
<a name="line391"></a> */
<a name="line392"></a>goog.ui.DrilldownRow.prototype.setDisplayable_ = function(display) {
<a name="line393"></a>  if (display &amp;&amp; !this.isInDocument()) {
<a name="line394"></a>    this.render();
<a name="line395"></a>  }
<a name="line396"></a>  if (this.displayed_ == display) {
<a name="line397"></a>    return;
<a name="line398"></a>  }
<a name="line399"></a>  this.displayed_ = display;
<a name="line400"></a>  if (this.isInDocument()) {
<a name="line401"></a>    this.getElement().style.display = display ? &#39;&#39; : &#39;none&#39;;
<a name="line402"></a>  }
<a name="line403"></a>  var selfObj = this;
<a name="line404"></a>  this.forEachChild(function(child) {
<a name="line405"></a>    child.setDisplayable_(display &amp;&amp; selfObj.expanded_);
<a name="line406"></a>  });
<a name="line407"></a>};
<a name="line408"></a>
<a name="line409"></a>
<a name="line410"></a>/**
<a name="line411"></a> * True iff this and all its DrilldownRow parents are displayable.  The
<a name="line412"></a> * value is an approximation to actual visibility, since it does not
<a name="line413"></a> * look at whether DOM nodes containing the top-level component have
<a name="line414"></a> * display: none, visibility: hidden or are otherwise not displayable.
<a name="line415"></a> * So this visibility is relative to the top-level component.
<a name="line416"></a> *
<a name="line417"></a> * @return {boolean} visibility of this relative to its top-level drilldown.
<a name="line418"></a> * @private
<a name="line419"></a> */
<a name="line420"></a>goog.ui.DrilldownRow.prototype.isVisible_ = function() {
<a name="line421"></a>  for (var component = this;
<a name="line422"></a>       component instanceof goog.ui.DrilldownRow;
<a name="line423"></a>       component = component.getParent()) {
<a name="line424"></a>    if (!component.displayed_)
<a name="line425"></a>      return false;
<a name="line426"></a>  }
<a name="line427"></a>  return true;
<a name="line428"></a>};
<a name="line429"></a>
<a name="line430"></a>
<a name="line431"></a>/**
<a name="line432"></a> * Create and return a TR element from HTML that looks like
<a name="line433"></a> * &quot;&lt;tr&gt; ... &lt;/tr&gt;&quot;.
<a name="line434"></a> *
<a name="line435"></a> * @param {string} html for one row.
<a name="line436"></a> * @param {Document} doc object to hold the Element.
<a name="line437"></a> * @return {Element} table row node created from the HTML.
<a name="line438"></a> * @private
<a name="line439"></a> */
<a name="line440"></a>goog.ui.DrilldownRow.createRowNode_ = function(html, doc) {
<a name="line441"></a>  // Note: this may be slow.
<a name="line442"></a>  var tableHtml = &#39;&lt;table&gt;&#39; + html + &#39;&lt;/table&gt;&#39;;
<a name="line443"></a>  var div = doc.createElement(&#39;div&#39;);
<a name="line444"></a>  div.innerHTML = tableHtml;
<a name="line445"></a>  return div.firstChild.rows[0];
<a name="line446"></a>};
<a name="line447"></a>
<a name="line448"></a>
<a name="line449"></a>/**
<a name="line450"></a> * Get the recursively rightmost child that is in the document.
<a name="line451"></a> *
<a name="line452"></a> * @return {goog.ui.DrilldownRow} rightmost child currently entered in
<a name="line453"></a> *     the document, potentially this DrilldownRow.  If this is in the
<a name="line454"></a> *     document, result is non-null.
<a name="line455"></a> * @private
<a name="line456"></a> */
<a name="line457"></a>goog.ui.DrilldownRow.prototype.lastRenderedLeaf_ = function() {
<a name="line458"></a>  var leaf = null;
<a name="line459"></a>  for (var node = this;
<a name="line460"></a>       node &amp;&amp; node.isInDocument();
<a name="line461"></a>       // Node will become undefined if parent has no children.
<a name="line462"></a>       node = node.getChildAt(node.getChildCount() - 1)) {
<a name="line463"></a>    leaf = node;
<a name="line464"></a>  }
<a name="line465"></a>  return /** @type {goog.ui.DrilldownRow} */ (leaf);
<a name="line466"></a>};
<a name="line467"></a>
<a name="line468"></a>
<a name="line469"></a>/**
<a name="line470"></a> * Search this node&#39;s direct children for the last one that is in the
<a name="line471"></a> * document and is before the given child.
<a name="line472"></a> * @param {goog.ui.DrilldownRow} child The child to stop the search at.
<a name="line473"></a> * @return {goog.ui.Component?} The last child component before the given child
<a name="line474"></a> *     that is in the document.
<a name="line475"></a> * @private
<a name="line476"></a> */
<a name="line477"></a>goog.ui.DrilldownRow.prototype.previousRenderedChild_ = function(child) {
<a name="line478"></a>  for (var i = this.getChildCount() - 1; i &gt;= 0; i--) {
<a name="line479"></a>    if (this.getChildAt(i) == child) {
<a name="line480"></a>      for (var j = i - 1; j &gt;= 0; j--) {
<a name="line481"></a>        var prev = this.getChildAt(j);
<a name="line482"></a>        if (prev.isInDocument()) {
<a name="line483"></a>          return prev;
<a name="line484"></a>        }
<a name="line485"></a>      }
<a name="line486"></a>    }
<a name="line487"></a>  }
<a name="line488"></a>  return null;
<a name="line489"></a>};
</pre>


</body>
</html>
